<template>
  <div class="share">
    <!-- <div class="share_top">
      <div class="share_head">分享赚钱</div>
      <div class="share_ma">
        <img :src="shareMa" alt="">
      </div>
      <div class="share_tishi col_66 f36">扫一扫注册聚融汇</div>
      <div id="Copy">
        <div ref="copyBtn"  @click="copyBtn" :data-clipboard-text="copyNews" class="global_btn copy share_btn">分享链接</div>
      </div>
    </div> -->

    <!-- <div class="fiex_height"> -->
      <!-- 客户更改之后的页面 -->
      <div class="big_img_box" :style="'height:'+height+'px'">
        <p id="qrcode" ref="qrcode"></p >
        <img class="big_img" :src="bigImg" alt="">
      </div>
      <!-- <div class="big_img_bottom"></div> -->
    <!-- </div> -->
    <!-- 底部导航栏 -->
    <foot-component ref="footerHeight" style="height:1.3333rem" :select = '1'/>
  </div>
</template>
<script>
let cliBtn;
import Clipboard from 'clipboard';
import footComponent from "@/components/layout/foot";
import QRCode from 'qrcodejs2'
export default {
  name: '',
  components: {
    footComponent
  },
  data() {
    return {
      bigImg: '',
      shareMa: require('@/common/image/ma.png'),
      copyNews: '123',
      height: '' // 盒子高度
    }
  },
  watch: {},
  mounted() {
    this.getInfo();
    // this.getNews();
    // 创建复制按钮
    cliBtn = new Clipboard('.copy');
    return cliBtn;
  },
  methods: {
    // 复制订单编号
    copy () {
      this.$refs.copyBtn.click();
    },
    copyBtn () {
      this.$toast('复制成功');
    },

    getInfo(){ // 客户更改后页面
      var h = document.documentElement.clientHeight || document.body.clientHeight;
      var t = this.$toast.loading({message: '正在加载数据', mask: true, duration: 9999})
      let footerHeight = Number(this.$refs.footerHeight.$el.style.height.slice(0,6))*75 / 2;
      this.height = h - footerHeight;
      let $this = this;
      let uid = localStorage.getItem('uid');
      let token = localStorage.getItem('token');
      let isVip = localStorage.getItem('isVip');
      var data = {u_id: uid,token:token};
      $this.$axios.post('index.php?m=user&c=qrcode', data).then(res=>{
        if(res.data.code === 1){
          t.clear();
          $this.bigImg = res.data.img;
          let qrcode = new QRCode('qrcode', {
            width: 125,  // 二维码宽度
            height: 125, // 二维码高度
            text:res.data.reg_url
          })
        } else {
          $this.$toast({
            message: res.data.msg,
            duration: 1000
          })
        }
      })
    },
    getNews(){ // 客户更改前页面
      let $this = this;
      let uid = localStorage.getItem('uid');
      let token = localStorage.getItem('token');
      var data = {u_id: uid,token:token};
      $this.$axios.post('index.php?m=user&c=qrcode', data).then(res=>{
        if(res.data.code === 1){
          $this.shareMa = res.data.url;
          $this.copyNews = res.data.url;
        } else {
          $this.$toast({
            message: res.data.msg,
            duration: 1000
          })
        }
      })
    }
  },
}
</script>
<style lang="less">
  .big_img_box{
    position: relative;
    // flex: 1;
    // height: 100%;
    .big_img{
    display: block;
    width: 100%;
    height: 100%;
    }
    p{
      position:absolute;
      top: 6.5rem;
      right: 0.45rem;
      @width: 40%;
      width: @width;
      height: @width;
    }
  }
  .big_img_bottom{
    height: 1.3333rem;
  }


</style>
